package com.itheima.youdianda.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.youdianda.common.BusinessException;
import com.itheima.youdianda.entity.YddUser;
import com.itheima.youdianda.mapper.YddUserMapper;
import com.itheima.youdianda.service.YddUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@Slf4j
public class YddUserServiceImpl  extends ServiceImpl<YddUserMapper, YddUser> implements YddUserService {

        @Override
        public void saveMobile(YddUser yddUser) {
            String mobile = yddUser.getMobile();
            List<YddUser> list = this.list();
            for (YddUser user : list) {
                String mobile1 = user.getMobile();
                if(mobile.equals(mobile1)){
                    throw new BusinessException("手机号已存在");
                }
            }
            super.save(yddUser);


        }
    }

